package com.merelyb.data.service.service.service.account;

import com.merelyb.data.service.common.MultiDataSourceContextHolder;
import com.merelyb.data.service.service.mybatis.bean.account.AccountBasic;
import com.merelyb.data.service.service.mybatis.dao.account.AccountBasicDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by LiM on 2017/11/14.
 */
@Service
public class AccountBasicService {
    @Autowired
    AccountBasicDao accountBasicDao;

    /**
     * 查询数据
     *
     * @param accountBasic
     * @return
     * @throws Exception
     */
    public List<AccountBasic> queryAllList(AccountBasic accountBasic) throws Exception {
        return accountBasicDao.queryAllList(accountBasic, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

    /**
     * 分页查询数据
     *
     * @param accountBasic
     * @return
     */
    public List<AccountBasic> queryListByLimit(AccountBasic accountBasic) {
        return accountBasicDao.queryListByLimit(accountBasic, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

    /**
     * 新增单条数据
     *
     * @param accountBasic
     * @throws Exception
     */
    public void addData(AccountBasic accountBasic) throws Exception {
        accountBasicDao.addData(accountBasic, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

    /**
     * 批量新增数据
     *
     * @param accountBasicList
     * @throws Exception
     */
    public void addData(List<AccountBasic> accountBasicList) throws Exception {
        accountBasicDao.addData(accountBasicList, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

    /**
     * 更新数据
     *
     * @param accountBasic
     * @throws Exception
     */
    public void updateData(AccountBasic accountBasic) throws Exception {
        accountBasicDao.updateData(accountBasic, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

    /**
     * 更新数据状态
     *
     * @param accountBasic
     * @throws Exception
     */
    public void deleteData(AccountBasic accountBasic) throws Exception {
        accountBasicDao.deleteData(accountBasic, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

    /**
     * 统计数量
     *
     * @param accountBasic
     * @return
     */
    public int getCount(AccountBasic accountBasic) {
        return accountBasicDao.getCount(accountBasic, MultiDataSourceContextHolder.DATA_ACCOUNT);
    }

}
